<extend name="Public/base" />
<block name="content">
<div id="content">
	<div id="content-header">
		<div id="breadcrumb">
			<a href="{:U('Index/index')}" title="首页" class="tip-bottom"><i class="icon-home"></i> 首页</a> 
			<a href="#" class="current">{$meta_title}</a>
		</div>
	</div>
	<div class="container-fluid">
		<br/>
		<button class="btn btn-info" id="add">拉取活动</button>
		
		<div class="row-fluid">
			<div class="span12">
				<div class="widget-box">
					<div class="widget-content ">
					<notempty name="_list">
						<form id="export-form" method="post" action="" autocomplete="off">
							<table class="table table-bordered table-striped">
								<thead>
									<tr>
										<th nowrap="nowrap">序号</th>
										<th>活动名称</th>
										<th>开始时间</th>
										<th>结束时间</th>
										<th>活动状态</th>
										<th>操作</th>
									</tr>
								</thead>
								<tbody>
									<volist name="_list" id="vo">
										<tr>
											<td class="taskStatus">{$i}</td>
											<td class="taskStatus">{$vo.activity_name|htmlspecialchars|msubstr=###,0,40}</td>
											<td class="taskStatus">{$vo.start_time|time_format}</td>
											<td class="taskStatus">{$vo.end_time|time_format}</td>
											<td class="taskStatus">{$vo.status_text}</td>
											<td class="taskStatus">
												<if condition="$vo.status lt 2 "><a href="{:U('activitySet?activity_id='.$vo['activity_id'])}"><i class="icon-cog"></i> 设置</a></if>
												<eq name="vo.status" value="0"><a href="{:U('changeStatus',array('activity_id'=>$vo['activity_id'],'status'=>'1'))}" class="ajax-get confirm"><i class="icon-cog"></i> 开始推荐</a></eq>
												<eq name="vo.status" value="1"><a href="{:U('changeStatus',array('activity_id'=>$vo['activity_id'],'status'=>'2'))}" class="ajax-get confirm"><i class="icon-cog"></i> 活动结束</a></eq>
												<eq name="vo.status" value="2"><a href="{:U('changeStatus',array('activity_id'=>$vo['activity_id'],'status'=>'3'))}" class="ajax-get confirm"><i class="icon-cog"></i> 生成回访任务</a></eq>
												<eq name="vo.status" value="3"><a href="{:U('changeStatus',array('activity_id'=>$vo['activity_id'],'status'=>'4'))}" class="ajax-get confirm"><i class="icon-cog"></i> 活动回访结束</a></eq>
												<eq name="vo.status" value="1">
												<a href="javascript:void(0);" class="a_but" onClick="addActivityJoin({$vo.activity_id});return false;">
												<i class="icon-cog"></i> 从活动管理系统中取报名数据  
												<img id="loading_{$vo.activity_id}" style="display:none;" src="__IMG__/loading.gif"></a>
												</eq>
												<if condition="($vo.status eq 1) OR ($vo.status eq 3)"><a href="{:U('setBindMember?activity_id='.$vo['activity_id'])}"><i class="icon-cog"></i> 分配</a></if>
											</td>
										</tr>
									</volist>
								</tbody>
							</table>
							<div class="dataTables_paginate fg-buttonset ui-buttonset fg-buttonset-multi ui-buttonset-multi paging_full_numbers" id="DataTables_Table_0_paginate">
								{$_page}
							</div>
						</form>
					<else/>
						<center>暂无内容</center>
					</notempty>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
<script type="text/javascript">
$(function (){
	//新增跳转页面
	$('#add').click(function(){
		$('button').attr('disabled',true);
		$.post("{:U('ServiceManage/addActivity')}",'',function(data){
			if(data.status == 1){
				$('button').attr('disabled',false);
				tke_alert(data.info,'alert-success');
				setTimeout(function(){
					if (data.url) {
						location.href=data.url;
					}else{
						location.reload();
					}
				},1500);
			}else{
				$('button').attr('disabled',false);
				tke_alert(data.info,'alert-error',3000);
			}
		})
	});
});

//拉取活动下报名数据
var i=1;
function addActivityJoin(activity_id){
	if(i==1){
		i=0;
		$('#loading_'+activity_id).show();//显示加载图片
		$.post("{:U('ServiceManage/addActivityJoin')}", {activity_id : activity_id}, function(data){
			if(data.status == 1){
				$('#loading_'+activity_id).hide();//隐藏加载图片
				tke_alert(data.info,'alert-success');
				setTimeout(function(){
					window.location.reload();
				},3000);
			}else{
				$('#loading_'+activity_id).hide();//隐藏加载图片
				tke_alert(data.info,'alert-error',3000);
			}
			i=1;
			return false;
		});
	}
}

//导航高亮
highlight_subnav("{:U('ServiceManage/index')}");
</script>
</block>